<template>
  <div class="card song-list-container">
    <div class="header">
      <span class="title">收藏歌单({{ collectionList.length }}个)</span>
      <span><i class="iconfont icon-more"></i></span>
    </div>
    <div class="list">
      <div
        class="song-item-container"
        v-for="(item, index) in collectionList"
        :key="index"
        @click="toPlayList(item.id)"
      >
        <div class="cover-wrap">
          <img class="cover" :src="item.coverImgUrl" alt="" />
        </div>
        <div class="content">
          <p class="title">{{ item.name }}</p>
          <p class="count">{{ item.trackCount }}首</p>
        </div>
        <div><i class="iconfont icon-more"></i></div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from "vue";
import { useRouter } from "vue-router";

export default defineComponent({
  name: "SongList",
  props: ["collectionList"],
  setup() {
    const router = useRouter();
    const toPlayList = (id: any) => {
      router.push(`/playlist/${id}`);
    };
    return {
      toPlayList,
    };
  },
});
</script>

<style scoped>
.song-list-container {
  margin: 0 32rem;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header .icon-more {
  color: var(--three-level);
}

.title {
  font-size: 24rem;
  color: var(--three-level);
}

.song-item-container {
  display: flex;
  align-items: center;
  margin-top: 16rem;
}

.song-item-container .icon-more {
  color: var(--three-level);
}

.cover-wrap {
  width: 100rem;
  height: 100rem;
  overflow: hidden;
  font-size: 0;
  border-radius: var(--sub-radius);
}

.cover {
  width: 100%;
  height: 100%;
}

.content {
  margin-left: 16rem;
  flex: 1;
  overflow: hidden;
}

.title {
  font-weight: bold;
  font-size: 28rem;
  margin-bottom: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.count {
  font-size: 22rem;
  color: var(--subtitle);
}
</style>
